<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/', function () {
////    return view('welcome');
////});
//后台需要通过登录验证，加一个中间键进行验证
Route::group(['middleware' => 'admin.auth','namespace'=>'Admin','prefix'=>'admin','as'=>'admin.'],function (){
//    后台首页路由
    Route::get('/','AdminController@index')->name('index');
    Route::resource('category','CategoryController');
    Route::get('getSonCategory/{id}','CategoryController@getSonCategory')->name('getSonCategory');
    Route::get('logout','LoginController@logout')->name('logout');
//    商品管理资源路由
    Route::resource('goods','GoodsController');
    Route::get('/order','OrderController@index')->name('order.index');
    Route::get('/changeStatus/{order}','OrderController@changeStatus')->name('order.changeStatus');
    Route::post('/updateStatus/{order}','OrderController@updateStatus')->name('order.updateStatus');
    Route::resource('/slider','SliderController');
    Route::get('permission','PermissionController@index')->name('permission.index');
    Route::get('permission/cache','PermissionController@cache')->name('permission.cache');
    Route::resource('role','RoleController');
//    角色权限路由配置
    Route::get('role/{role}/permission','RoleController@permission')->name('role.permission');
    Route::post('role/{role}/permission','RoleController@permissionUpdate')->name('role.permission');
    //    用户角色路由配置
    Route::resource('user','UserController');
    Route::get('user/{user}/role','UserController@role')->name('user.role');
    Route::post('user/{user}/role','UserController@roleUpdate')->name('user.role');
    //    搜索用户路由配置
    Route::post('search/user','SearchController@searchUser')->name('search.user');
});
//后台不需要登录验证的路由组
Route::group(['namespace'=>'Admin','prefix'=>'admin','as'=>'admin.'],function (){
    Route::get('/login','LoginController@index')->name('login');
    Route::post('/login','LoginController@login')->name('login');
});

//公共的路由组
Route::group(['namespace'=>'Common','prefix'=>'common','as'=>'common.'],function (){
    Route::any('upload/make','UploadController@make')->name('upload.make');
    Route::any('upload/lists','UploadController@lists')->name('upload.lists');
    Route::any('upload/layuiUpload','UploadController@layuiUpload')->name('upload.layuiUpload');
    Route::any('code/send','CodeController@send')->name('code.send');
    Route::any('code/user','CodeController@sendToUser')->name('code.sendToUser');
});

//前台路由组
Route::group(['namespace'=>'Home','as'=>'home.'],function (){
    Route::get('/','HomeController@index')->name('index');
    Route::get('/lists/{category}','HomeController@lists')->name('lists');
    Route::get('/content/{good}/{bale?}','HomeController@content')->name('content');
    Route::get('/login','LoginController@index')->name('login');
    Route::post('/login','LoginController@login')->name('login');
    Route::get('/logout','LoginController@logout')->name('logout');
    Route::get('/register','RegisterController@index')->name('register');
    Route::post('/register','RegisterController@register')->name('register');

    //微信支付异步通知路由
    Route::post('wxPayResult','PayController@wxPayResult')->name('wxPayResult');
//  站内搜索路由
    Route::get('/search/{hotWord?}','HomeController@search')->name('search.goods');

});

//前台需要验证的路由组
Route::group(['middleware'=>'home.auth','namespace'=>'Home','as'=>'home.'],function (){
    Route::get('/addCart/{goods_id}/{bale_id}/{num}','CartController@addCart')->name('addCart');
    Route::get('/myCart','CartController@index')->name('cart.index');
    Route::get('/deleteCart/{cart}','CartController@delete')->name('cart.delete');
    Route::get('/destory/{cart}','CartController@destory')->name('cart.destory');
    Route::get('/addNum/{cart_id}/{goods_price}/{bale_attach}','CartController@addNum')->name('cart.addNum');
    Route::get('/deleteNum/{cart_id}/{goods_price}/{bale_attach}','CartController@deleteNum')->name('cart.deleteNum');
    Route::get('/center','CenterController@index')->name('center');
    Route::get('/myOrder','CenterController@myOrder')->name('center.myOrder');
    Route::get('/allOrder','CenterController@allOrder')->name('center.allOrder');
    Route::get('/edit/{info}','CenterController@edit')->name('center.edit');
    Route::get('/checkCode','CenterController@checkCode')->name('center.checkCode');
    Route::post('/checkCode','CenterController@checkCodePost')->name('center.checkCode');
    Route::post('/update/inform/{user}','CenterController@updateInform')->name('center.updateInform');
    Route::post('/search_order','CenterController@searchOrder')->name('center.searchOrder');
    Route::resource('/address','AddressController');
    Route::get('/setDefault/{address}','AddressController@setDefault')->name('setDefault');
    Route::resource('/order','OrderController');
    Route::post('/order/storeOne','OrderController@storeOne')->name('order.storeOne');
    Route::get('/order_lists/{ids}','OrderController@lists')->name('order.lists');
    Route::post('/order_buy/{huopin}','OrderController@buy')->name('order.buy');
    Route::get('/order_pay/{order_num}','PayController@index')->name('order.pay');
    Route::get('/order_status/{order_status}','OrderController@orderStatus')->name('order.status');
    //检测订单支付状态
    Route::post('checkOrderStatus','PayController@checkOrderStatus')->name('checkOrderStatus');
    Route::get('/collect/{good}','CollectController@make')->name('collect.make');
    Route::get('/myCollect','CollectController@myCollect')->name('collect.myCollect');
});
